package com.demo.component.base.model.communication;

import jakarta.annotation.Nullable;
import lombok.Getter;
import org.springframework.http.HttpHeaders;

@Getter
public class RequestResult {
    private boolean isSuccess;

    private String internalStatus;

    private String message;

    private HttpHeaders httpHeaders;

    public String getMessageWithStatus() {
        return this.message + ", Status: " + internalStatus;
    }

    public void setFailure(String errorMessage, @Nullable String internalStatus) {
        this.isSuccess = false;
        this.setMessages(errorMessage, internalStatus);
    }

    public void setSuccess(String successMessage, @Nullable String internalStatus) {
        this.isSuccess = true;
        this.setMessages(successMessage, internalStatus);
    }

    public void setHttpHeaders(HttpHeaders httpHeaders){
        this.httpHeaders = httpHeaders;
    }

    private void setMessages(String message, @Nullable String internalStatus) {
        this.message = message;
        this.internalStatus = internalStatus;
    }

}
